<?php
defined("AT_EXE") or die ("CORE VARIABLE IS NOT DEFINED.");
class PageController extends Controller {
	public function __construct(){
		$this->calledClass(get_class($this));
	}
	public function index(){
		$job = $this->loadModel("Job");
		$config = $this->loadModel("Config");
		$visitor = $this->loadModel("Visitor");
		$category = $this->loadModel("Categorie");
		$this->set(array("job_location"=>$category->getCategories(1)));
		$this->set(array("job_category"=>$category->getCategories(23)));
		$this->getAllCategories(); // load all location and category of job
		//load this function to load function update hit from controller jobs
		$job->update_job_hit();
		$recordConfig = $config->findAsObject(array("id="=>1));
			
		$this->set(array("visitor"=>$visitor->getCounter()));
		
		//get all urget job posted
		$this->set(array("urgent_job"=>$job->get_active_urgent_jobs()));
		
		//get all gold job posted
		$this->set(array("gold_job"=>$job->get_active_gold_jobs()));
		
		//get all platium job posted
		//$this->set(array("platinum_job"=>$job->get_active_platinum_jobs(1,$recordConfig->limit_view_standard,array(),array(),array("id"),"DESC")));
			
		//get all urget job posted
		//$this->set(array("urgent_job"=>$job->get_active_urgent_jobs()));
			
		//get alll free job posted
		//$this->set(array("free_job"=>$job->get_active_free_jobs(1,$recordConfig->limit_view_standard,array(),array(),array("id"),"DESC")));
			
		//get number of job posted and currently action not over deadline
		//$this->set(array("standard_job"=>$job->get_active_standard_jobs()));
			
		//$this->set(array("premium_job"=>$job->get_active_premium_jobs()));
		//get all total job
		//$this->set(array("total_job"=>$job->get_total_job())) ;

		//get logo employer
		$this->set(array("record"=>$job->get_logo_employer()));
		
		$this->loadAdvert();
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Home | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$this->layout="lightblue/lightblue";
		$this->render();
	}
	public function destroyCan(){
		Session::kill("candidate");
	}
	public function destroyEmp(){
		Session::kill("employer");
	}
	public function searchall(){
		$visitor = $this->loadModel("Visitor");
		$ads = $this->loadModel("Advert");
		$category = $this->loadModel("Categorie");
		$job = $this->loadModel("Job");
		$this->set(array("mnu"=>"home"));
		/**/
		$this->set(array("locations"=>$category->getCategories(1)));
		$this->set(array("jobcategories"=>$category->getCategories(23)));
		/**/
		$src = $this->get("s")!==NULL?urldecode($this->get("s")):"";
		$cate = $this->get("c")!==NULL?urldecode(str_replace(array('-'),'/',$this->get("c"))):"";
		$loca = $this->get("l")!==NULL?urldecode($this->get("l")):"";
		$this->set(array("search"=>$src,"cate"=>$cate,"loca"=>$loca));
		$wheres = array();
		$this->set(array("standard_search"=>$src));
		$this->set(array("standard_searchcate"=>$cate));
		$this->set(array("standard_searchloca"=>$loca));
		if($cate!="")$wheres["job_category="]=$cate;
		if($loca!="")$wheres["location_category="]=$loca;
		/* start catch standard ,premium */
		$this->set(array("search_std"=>$this->get("search_std")));
		$this->set(array("by"=>$this->get("by")));
		if($cate!="")$search=array("job_category"=>$cate);
		if($loca!="")$search=array("location_category"=>$loca);
		$by = $this->get("by");
		if($by=="standard"){
			$this->set(array("main_body"=>"standard"));
			$this->set(array("standards"=>$job->getSearchStandard($this->get("page"),20,$search,$wheres)));
		}elseif($by=="premium"){
			$this->set(array("main_body"=>"premium"));
			$this->set(array("premiums"=>$job->getSearchPremium($this->get("page"),20,$search,$wheres)));
		}elseif($by="all"){
			$this->set(array("jobs"=>$job->getList($this->get("page"),20,$src,array("title","description","posted_by"),array("id"),"DESC",$wheres)));
			$this->set(array("main_body"=>"searchall"));
		}
		/* end catch standard ,premium */
		$adverts = $ads->getAdvertsAndCategorize();
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
		$this->set(array("visitor"=>$visitor->getCounter()));
		$this->layout="home3";
		$this->render();
	}
	public function luckydraw(){
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Lucky Draw | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$this->layout="lightblue_underconstruction";
		$this->render();
		exit();
		$this->set(array("mnu"=>"home"));
		/**/
		$category = $this->loadModel("Categorie");
		$this->set(array("locations"=>$category->getCategories(1)));
		$this->set(array("jobcategories"=>$category->getCategories(23)));

		/**/
		$job = $this->loadModel("Job");
		$config = $this->loadModel("Config");
		$recordConfig = $config->findAsObject(array("id = "=>1));
		/*modified by : chamnan. to display new job post at up*/
		$gold_job = $job->getPremiumJobs(1,$recordConfig->limit_view_premium,array(),array(),array("id"),"DESC") ;
		$gold_job["totalpages"]=1;
		$platinum_job = $job->getStandardJobs(1,$recordConfig->limit_view_standard,array(),array(),array("id"),"DESC") ;
		$platinum_job["totalpages"]=1;
		$this->set(array("gold_job"=>$gold_job));
		$this->set(array("platinum_job"=>$platinum));
		/* end */
		$this->loadAdvert();
		$this->set(array("main_body"=>"luckydraw"));
		//$visitor=$this->loadModel("Visitor");
		//$this->set(array("visitor"=>$visitor->getCounter()));
		$this->layout="lightblue";
		$this->render();
	}
	/* Modify by: Dimsidet, Web Developer
	 * Modify date: 2-May-2014
	* Return : search standard front page
	* */
	public function standardjob(){
		$this->set(array("mnu"=>"home"));
		$route = $this->getRoute();
		$request = $route[request];
		$this->set(array("route"=>$request->getAction()));
		/* start catch standard sidet */
		if($this->get("by")=="standard"){
			$this->set(array("by"=>$this->get("by")));
		}else{
			$this->set(array("by"=>$this->get("standard")));
		}
		/* end sidet */
		/**/
		$config = $this->loadModel("Config");
		$category = $this->loadModel("Categorie");
		$this->set(array("locations"=>$category->getCategories(1)));
		$this->set(array("jobcategories"=>$category->getCategories(23)));
		$recordConfig = $config->findAsObject(array("id = "=>1));
		/**/
		$job = $this->loadModel("Job");
		$src = $this->get("s")!==NULL?urldecode($this->get("s")):"";
		$cate = $this->get("c")!==NULL?urldecode(str_replace(array('-'),'/',$this->get("c"))):"";
		$loca = $this->get("l")!==NULL?urldecode($this->get("l")):"";
		$this->set(array("search"=>$src,"cate"=>$cate,"loca"=>$loca));
		$wheres = array();
		$search = array();
		if($src!="")$search=array("title"=>$src,"posted_by"=>$src);
		//if($src!="")$search=array("company_name"=>$src);
		if($cate!="")$wheres["job_category="]=$cate;
		if($loca!="")$wheres["location_category="]=$loca;
		$this->set(array("standard_searchcate"=>$cate));
		$this->set(array("standard_searchloca"=>$loca));
		$this->set(array("standard_search"=>$src));
		$this->set(array("standard_if"=>$this->get("standard")));
		$this->set(array("standards"=>$job->getSearchStandard($this->get("page"),$recordConfig->limit_view_standard,$search,$wheres)));
		$this->set(array("standard_job"=>$job->get_active_standard_jobs()));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
			
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
		$visitor = $this->loadModel("Visitor");
		$this->set(array("visitor"=>$visitor->getCounter()));
		$this->set(array("main_body"=>"standard"));
		$this->layout="home3";
		$this->render();
	}
	/* Modify by: Dimsidet, Web Developer
	 * Modify date: 2-May-2014
	* Return : premuim front page
	* */
	public function premiumjob(){
		$this->set(array("mnu"=>"home"));
		/* start catch premium sidet */
		if($this->get("by")=="premium"){
			$this->set(array("by"=>$this->get("by")));
		}else{
			$this->set(array("by"=>$this->get("premium")));
		}
		/* end catch premium sidet */
		$category = $this->loadModel("Categorie");
		$this->set(array("locations"=>$category->getCategories(1)));
		$this->set(array("jobcategories"=>$category->getCategories(23)));
		/**/
		$job = $this->loadModel("Job");
		$src = $this->get("s")!==NULL?urldecode($this->get("s")):"";
		$cate = $this->get("c")!==NULL?urldecode(str_replace(array('-'),'/',$this->get("c"))):"";
		$loca = $this->get("l")!==NULL?urldecode($this->get("l")):"";
		$this->set(array("search"=>$src,"cate"=>$cate,"loca"=>$loca));
		$wheres = array();
		$search = array();
		if($src!="")$search=array("title"=>$src,"posted_by"=>$src);
		//if($src!="")$search=array("company_name"=>$src);
		if($cate!="")$wheres["job_category="]=$cate;
		if($loca!="")$wheres["location_category="]=$loca;
		$this->set(array("l"=>$loca));
		//echo $search;exit();
		$this->set(array("premiums"=>$job->getSearchPremium($this->get("page"),20,$search,$wheres)));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
			
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
		//$visitor = $this->loadModel("Visitor");
		//$this->set(array("visitor"=>$visitor->getCounter()));
		$this->set(array("main_body"=>"premium"));
		$this->layout="home3";
		$this->render();
	}

	public function mainpage(){
		$this->set(array("mnu"=>"home"));
		$this->layout = "main" ;
		$this->render();
	}
	public function product(){
		$this->set(array("mnu"=>"product"));
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		//print_r( $adverts );
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Products | HR Cambodia - The best website to find job","active_menu"=>"product" ));
			
		$this->layout="product";
		$this->render();
	}
	public function service(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Service | HR Cambodia - The best website to find job","active_menu"=>"service" ));
			
		$this->layout="service";
		$this->render();
	}
	public function recruitment(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Recruitment | HR Cambodia - The best website to find job","active_menu"=>"recruitment" ));
			
		$this->layout="recruitment";
		$this->render();
	}
	public function cvscreening(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"CV Screening | HR Cambodia - The best website to find job","active_menu"=>"cvscreening" ));
			
		$this->layout="cvscreening";
		$this->render();
	}
	public function jobposting(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Jpb Posting | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$this->layout="jobposting";
		$this->render();
	}
	public function advertisewithus(){
		$this->set(array("mnu"=>"service"));
		$this->layout="advertisewithus";
		$this->render();
	}
	public function trainingdevelopement(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Training and Development | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$this->layout="trainingdevelopement";
		$this->render();
	}
	public function policyprocedure(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Policy and Procedure | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$this->layout="policyprocedure";
		$this->render();
	}
	public function about(){

		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"About | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		//print_r( $adverts );
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		$this->layout="about";
		$this->render();
	}
	public function contact(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Contact | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		//print_r( $adverts );
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		$this->layout="contact";
		$this->render();
	}
	public function disclaimer(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Disclaimer | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		//print_r( $adverts );
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		$this->layout="disclaimer";
		$this->render();
	}
	public function supportrequest(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Support Request | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		//print_r( $adverts );
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		$this->layout="support_request";
		$this->render();
	}
	public function feedback(){
			
		// set title of the page and set the top menu to be active.
		$this->set(array("title"=>"Feedback | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		//print_r( $adverts );
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		$this->layout="feedback";
		$this->render();
	}
	public function knowledge(){
			
		$this->set(array("title"=>"Knowledge | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
		$this->layout="knowledge_base";
		$this->render();
	}
	public function articles(){
		$this->layout="articles";
		$this->render();
	}
	public function writeFormalCv(){
		$this->layout="write_formal_cv";
		$this->render();
	}
	public function seeker(){
		$this->layout="seeker";
		$this->render();
	}
	public function employer(){
		$this->layout="employer";
		$this->render();
	}
	public function scholarship(){
			
		$this->set(array("title"=>"Scholarship | HR Cambodia - The best website to find job","active_menu"=>"scholarship" ));
			
		$this->layout="lightblue_underconstruction";
		$this->render();
		exit();
		$this->set(array("mnu"=>"scholarship"));
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		//print_r( $adverts );
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		$this->layout="scholarship";
		$this->render();
	}
	public function help(){
			
		$this->set(array("title"=>"Help | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$this->layout="lightblue_underconstruction";
		$this->render();
		exit();
	}
	public function university(){
			
		$this->set(array("title"=>"University | HR Cambodia - The best website to find job","active_menu"=>"university" ));
			
		$this->layout="lightblue_underconstruction";
		$this->render();
		exit();
		$this->set(array("mnu"=>"university"));
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		$this->layout="university";
		$this->render();
	}
	public function website(){
			
		$this->set(array("title"=>"Website | HR Cambodia - The best website to find job","active_menu"=>"home" ));
			
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		//print_r( $adverts );
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
			
		$this->layout="service";
		$this->render();
	}
	public function display(){
		$user = $this->loadModel("User");
		//$this->set(array("list"=>$user->queryAll("select * from users")));
		//$this->set(array("list"=>$user->getAsArrayKey(array("username","password","address"))));
		$this->set(array("list"=>$user->getList($this->get("page"),$this->get("perpage")?$this->get("perpage"):20,$this->get("search"),array("username"))));
		/* starting call table.at page(action)  */
		$this->layout = "table" ;
		$this->render();
		/* ending call table.at page(action)  */
	}
	public function addNew(){
		if(isset($_POST["username"])){
			$user = $this->loadModel("User");
			$user->save(array("username"=>$this->get("username"),"password"=>$this->get("password"),"address"=>$this->get("address"),"phone"=>$this->get("phone"),"email"=>$this->get("email"),"telephone"=>$this->get("telephone"),"family"=>$this->get("family")));
			$this->display();
		}else{
			$this->layout = "new" ;
			$this->render();
		}
	}
	public function edit(){
		$user = $this->loadModel("User");
		$user->findObject(array("id"=>$this->get("pid")));
		$this->set(array("arrFind"=>$user->findObject(array("id"=>$this->get("pid")))));
		$this->layout ="edit";
		$this->render();
	}
	public function saveEdit(){
		if(isset($_POST["username"])){
			$user = $this->loadModel("User");
			$user->edit(array("username"=>$this->get("username"),"password"=>$this->get("password"),"address"=>$this->get("address"),"phone"=>$this->get("phone"),"email"=>$this->get("email"),"telephone"=>$this->get("telephone"),"family"=>$this->get("family")),array("id"=>$this->get("pid")));
			$this->display();
		}else{
			$this->render("edit");
		}
	}
	public function delete(){
		$user = $this->loadModel("User");
		$this->set(array("arrFind"=>$user->delete(array("id"=>$this->get("pid")))));
		$this->set(array("list"=>$user->getList(1,$this->get("perpage")?$this->get("perpage"):20,"",array("username"))));
		$this->layout ="table";
		$this->render();
	}
	public function loadAdvert(){
		$ads = $this->loadModel("Advert");
		$adverts = $ads->getAdvertsAndCategorize();
		$this->set(array("adstopleft"=>isset($adverts[1])?$adverts[1]:array()));
		$this->set(array("adstopcenter"=>isset($adverts[2])?$adverts[2]:array()));
		$this->set(array("adstopright"=>isset($adverts[3])?$adverts[3]:array()));
		$this->set(array("adsmiddleleft"=>isset($adverts[4])?$adverts[4]:array()));
		$this->set(array("adsmiddlecenter"=>isset($adverts[5])?$adverts[5]:array()));
		$this->set(array("adsmiddleright"=>isset($adverts[6])?$adverts[6]:array()));
		$this->set(array("adsbottom"=>isset($adverts[7])?$adverts[7]:array()));
	}
	public function cv_template(){
			
		$this->set(array("title"=>"CV Template | HR Cambodia - The best website to find job","active_menu"=>"cv_template" ));
			
		$this->set(array("cv_layout"=>"cv_template"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_sample(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_sample"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_classic(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_classic"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_contemporary(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_contemporary"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_sample_contemporary(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_sample_contemporary"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_sample_standard(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_sample_standard"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_empasis(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_empasis"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_professional(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_professional"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_traditional(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_traditional"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_executive(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_executive"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cv_standard(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_standard"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_internship(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_template_internship"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_template(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_template"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_sample(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_sample"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_space_saver(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_space_saver"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_teacher_professional(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_teacher_professional"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_professional_business(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_professional_business"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_modern_reception(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_modern_reception"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_template_general_purpose(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_template_general_purpose"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_driver_classic(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_driver_classic"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_driver_modern(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_driver_modern"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_driver_professional(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_driver_professional"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_baker_traditional(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_baker_traditional"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_baker_modern(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_baker_modern"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_baker_executive(){
			
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_baker_executive"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function job_tip(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"job_tip"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function resume_tip(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cv_tip"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function cover_letter_tip(){
		$this->set(array("mnu"=>"cv_guideline"));
		$this->set(array("cv_layout"=>"cl_tip"));
		$this->loadAdvert();
		$this->layout="cv_guideline";
		$this->render();
	}
	public function scoring(){
			
		$this->set(array("title"=>"Score | HR Cambodia - The best website to find job","active_menu"=>"scoring" ));
			
		$this->layout="scoring";
		$this->render();
	}
	/**
	 * @author Mr. Noeur Phireak
	 * @return All job location and job category with number of jobs posted
	 * Date : 2014-June-19
	 */
	public function getAllCategories(){
		$job_category = $this->loadModel("Job");
		$this->set(array("job_categories"=>$job_category->get_job_in_categories()));
		$this->set(array("job_locations"=>$job_category->get_job_in_locations()));
	}
}